#include "ThreadPoolManager.h"
#include <utility>

AMCAX_EXCHANGE_NAMESPACE_BEGIN

namespace InterOp {

ThreadPoolManager::ThreadPoolManager()
{

}

void ThreadPoolManager::InitThreadPool(size_t poolSize)
{
    if (isInit) {
        return ;
    }
    if (nullptr != pool_)
    {
        return; // 避免多次初始化线程池
    }
    pool_ = std::make_unique<ThreadPoolInstance>((int)poolSize);   
    isInit = true ;
}



// add new work item to the pool
// template<class F, class... Args>
// auto ThreadPoolManager::AddWorker(F&& f, Args&&... args) 
//     -> std::future<typename std::result_of<F(Args...)>::type>
// {
//     if (!isInit) {
//         throw std::runtime_error("Threadpool not init");
//     }
//     return pool_->enqueue(f,std::forward<Args>(args)...) ;
// }

}

AMCAX_EXCHANGE_NAMESPACE_END